#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include "nrfx_clock.h"
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(dev_clock, LOG_LEVEL_INF);

// 高频128Mhz 运行模式.
static int hfclock_config_and_start(void)
{
	int ret;

	/* Use this to turn on 128 MHz clock for cpu_app */
	ret = nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1);

	ret -= NRFX_ERROR_BASE_NUM;
	if (ret) {
		return ret;
	}

	nrfx_clock_hfclk_start();
	while (!nrfx_clock_hfclk_is_running()) {
	}

	return 0;
}

// 初始化高频时钟128Mhz运行模式. 因为SPI配置的时候会判断当前是否在 高频模式,
SYS_INIT(hfclock_config_and_start, POST_KERNEL, 0);
